package com.jhw.ymcc.feign;

import com.jhw.doc.CourseDoc;
import com.jhw.ymcc.exception.GlobalErrorCode;
import com.jhw.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author jhw
 * @create 2022/10/12
 */
@Component
public class SearchServicefallbackFactory implements FallbackFactory<SearchService> {
    @Override
    public SearchService create(Throwable cause) {
        cause.printStackTrace();
        return new SearchService() {
            @Override
            public JSONResult saveCourseEs(CourseDoc courseDoc) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }

            @Override
            public JSONResult delCourseEs(CourseDoc courseDoc) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }
        };
    }
}
